//指令集                                  
`define   CMD_RESET       8'hc0           
`define   CMD_READ        8'h03           
`define   CMD_RD_RXBUF    8'h90           
`define   CMD_WRITE       8'h02           
`define   CMD_WR_TXBUF    8'h40           
`define   CMD_RTS         8'h81           
`define   CMD_RD_STATUS   8'ha0           
`define   CMD_RX_STATUS   8'hb0           
`define   CMD_BIT_M       8'h05           
                                          
//初始化状态参数                          
`define     INIT_IDLE          8'd0
`define     INIT_SPCR          8'd1
`define     DELAY_10MS         8'd2
`define     INIT_SPER1         8'd3  
`define     SET_BIT_TIME       8'd4  
`define     BIT_TIM_ADDR       8'd5   
`define     BIT_TIM_CNF3       8'd6   
`define     BIT_TIM_CNF2       8'd7   
`define     BIT_TIM_CNF1       8'd8   
`define     WAIT_2             8'd9
`define     CLR_SPIINT2        8'd10
`define     INIT_SPER2         8'd11   
`define     INIT_CANINTE       8'd12   
`define     CANINTE_ADDR       8'd13   
`define     SET_CANINTE        8'd14   
`define     WAIT_3             8'd15
`define     CLR_SPIINT3        8'd16
`define     INIT_SPER3         8'd17   
`define     INIT_RXB0CTRL      8'd18   
`define     RXB0CTRL_ADDR      8'd19   
`define     SET_RXB0CTRL       8'd20   
`define     WAIT_4             8'd21
`define     CLR_SPIINT4        8'd22
`define     INIT_SPER4         8'd23   
`define     INIT_RXB1CTRL      8'd24   
`define     RXB1CTRL_ADDR      8'd25   
`define     SET_RXB1CTRL       8'd26   
`define     WAIT_5             8'd27
`define     CLR_SPIINT5        8'd28
`define     INIT_SPER5         8'd29   
`define     INIT_RXF0SIDH      8'd30   
`define     FILT_REG0_ADDR     8'd31   
`define     SET_FILT0_REG1     8'd32   
`define     SET_FILT0_REG2     8'd33   
`define     SET_FILT0_REG3     8'd34   
`define     SET_FILT0_REG4     8'd35   
`define     SET_FILT1_REG1     8'd36   
`define     SET_FILT1_REG2     8'd37   
`define     SET_FILT1_REG3     8'd38   
`define     SET_FILT1_REG4     8'd39   
`define     SET_FILT2_REG1     8'd40   
`define     SET_FILT2_REG2     8'd41   
`define     SET_FILT2_REG3     8'd42   
`define     SET_FILT2_REG4     8'd43   
`define     WAIT_6             8'd44
`define     CLR_SPIINT6        8'd45
`define     INIT_SPER6         8'd46   
`define     INIT_RXF3SIDH      8'd47   
`define     FILT_REG3_ADDR     8'd48   
`define     SET_FILT3_REG1     8'd49   
`define     SET_FILT3_REG2     8'd50   
`define     SET_FILT3_REG3     8'd51   
`define     SET_FILT3_REG4     8'd52   
`define     SET_FILT4_REG1     8'd53   
`define     SET_FILT4_REG2     8'd54   
`define     SET_FILT4_REG3     8'd55   
`define     SET_FILT4_REG4     8'd56   
`define     SET_FILT5_REG1     8'd57   
`define     SET_FILT5_REG2     8'd58   
`define     SET_FILT5_REG3     8'd59   
`define     SET_FILT5_REG4     8'd60   
`define     WAIT_7             8'd61
`define     CLR_SPIINT7        8'd62
`define     INIT_SPER7         8'd63   
`define     INIT_RXMSIDH       8'd64   
`define     MASK0_ADDR         8'd65   
`define     SET_RXM0SIDH       8'd66   
`define     SET_RXM0SIDL       8'd67   
`define     SET_RXM0EID8       8'd68   
`define     SET_RXM0EID0       8'd69   
`define     SET_RXM1SIDH       8'd70   
`define     SET_RXM1SIDL       8'd71   
`define     SET_RXM1EID8       8'd72   
`define     SET_RXM1EID0       8'd73   
`define     WAIT_8             8'd74
`define     CLR_SPIINT8        8'd75
`define     INIT_SPER8         8'd76   
`define     INIT_RX_FOOT       8'd77   
`define     BFPCTRL_ADDR       8'd78   
`define     SET_BFPCTRL        8'd79   
`define     SET_TXRTSCTRL      8'd80   
`define     WAIT_9             8'd81
`define     CLR_SPIINT9        8'd82
`define     INIT_SPER9         8'd83   
`define     OVER_SET_MD        8'd84   
`define     OCANCTRL_ADDR      8'd85    
`define     OSET_MODE          8'd86     
`define     WAIT_10            8'd87
`define     DELAY_1MS          8'd88
`define     CLR_SPIINT10       8'd89
`define     LOOP_SPER          8'd90
`define     LOOP_WRITE         8'd91
`define     LOOP_DATA1         8'd92
`define     LOOP_DATA2         8'd93
`define     LOOP_DATA3         8'd94
`define     LOOP_DATA4         8'd95
`define     LOOP_DATA5         8'd96
`define     LOOP_DATA6         8'd97
`define     LOOP_DATA7         8'd98
`define     LOOP_DATA8         8'd99
`define     LOOP_DATA9         8'd100
`define     LOOP_DATA10        8'd101
`define     LOOP_DATA11        8'd102
`define     LOOP_DATA12        8'd103
`define     LOOP_DATA13        8'd104
`define     WAIT_12            8'd105
`define     CLR_SPIINT12       8'd106 
`define     INIT_SPER_TXREQ    8'd107
`define     WR_TXB0CTRL        8'd108
`define     WR_TXB0CTRL_ADDR   8'd109
`define     TEST_SET_TXREQ     8'd110
`define     WAIT_13            8'd111
`define     CLR_SPIINT13       8'd112
`define     INIT_OVER          8'd113
`define     INIT_RST_SPER      8'd114  
`define     POWERUP_RESET      8'd115  
`define     RESET_WAIT         8'd116  
`define     CLR_RESET_INT      8'd117                               
//work state
`define    MPC2515_DONE     5'd0
`define    RD_STATUS        5'd1
`define    STATUS_WAIT      5'd2
`define    STATUS_ADJUST    5'd3
`define    RD_RX_STATUS     5'd4
`define    WAIT_RX_STATUS   5'd5
`define    RCV_OR_NOT       5'd6
`define    RD_RXBnDLC       5'd7
`define    RD_LEN_WAIT      5'd8
`define    RD_BUF           5'd9
`define    WAIT_RX_DA       5'd10 
`define    RD_RFIFO         5'd11 
`define    RD_DISCARD       5'd12
`define    WR_PCIFIFO       5'd13  
`define    RST_RX_INTR      5'd14  
`define    WAIT_RXINT_OVER  5'd15  
`define    DELAY_5CLK       5'd16  
`define    RST_TX_INTR      5'd17  
`define    WAIT_TX_INTR     5'd18  
`define    RST_TXREQ        5'd19   
`define    WAIT_TXREQ       5'd20   
`define    RD_PCIFIFO       5'd21  
`define    LOAD_BUF         5'd22  
`define    WAIT_TX_OVER     5'd23  
`define    SET_TXREQ        5'd24  
`define    WAIT_SET_TXREQ   5'd25 

                 









































